home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr53 / pctv4n_1.zip / FASTHEX.ASM < prev    next >
Assembly Source File  |  1993-06-10  |  697b  |  39 lines

  1. ; Convert byte in AL into ASCII representation in AX
  2. ;   (AL = MSB, AH=LSB)
  3. ; Uses Turbo Assembler
  4. IDEAL
  5. MODEL SMALL
  6. CODESEG
  7. hexbyte_small:
  8.         db 0d4h         ; AAM 16 !
  9.         db 16
  10.         add     al, 90h
  11.         daa
  12.         adc     al, 40h
  13.         daa
  14.         xchg    ah, al
  15.         add     al, 90h
  16.         daa
  17.         adc     al, 40h
  18.         daa
  19.         ret
  20.  
  21. hexbyte_fast:
  22.         mov     bx, OFFSET hextbl
  23.         mov     ah, al
  24.  
  25.         ; high nybble
  26.         and     al, 0fh
  27.         xlat
  28.  
  29.         ; low nybble
  30.         xchg    ah, al
  31.         mov     cl, 4
  32.         shr     al, cl
  33.         xlat
  34.         ret
  35.  
  36. DATASEG
  37. hextbl  DB '0123456789ABCDEF'
  38. END
  39.